#include "timeline.h"

#include <QPainter>
#include <QFont>

TimeLine::TimeLine(QWidget *parent) :
    QWidget(parent){
}

void TimeLine::paintEvent(QPaintEvent *){
    QPainter painter(this);
    painter.setBrush(QColor{50,50,50});
    painter.drawRect(rect());
}

QString TimeLine::regulateTime(regTime time, int sec) {
    QString mi;
    QString se;
    time.second += sec;
    while (time.second>60) {
        time.second -= 60;
        time.minute += 1;
    }
    while (time.minute>60) {
        time.hour += 1;
        time.minute -= 60;
    }
    while (time.second<0) {
        time.second += 60;
        time.minute -= 1;
    }
    while (time.minute<0) {
        time.hour -= 1;
        time.minute += 60;
    }
    if (time.minute<10){
        mi = "0"+QString::number(time.minute);
    } else {
        mi = QString::number(time.minute);
    }
    if (time.second<10){
        se = "0"+QString::number(time.second);
    } else {
        se = QString::number(time.second);
    }
    return QString("%1:%2:%3").arg(QString::number(time.hour)).arg(mi).arg(se);
}
